package net.yxsoft.controller.pc.sysmgt.common.validator;

import com.jfinal.core.Controller;
import net.yxsoft.controller.common.validator.BaseValidator;
import net.yxsoft.model.infrastructure.TsCode;
import rapid.core.ContextStateEnum;
import rapid.core.TResult;

/**
 * Created by Administrator on 2016/6/28.
 */

public class CodeValidator extends BaseValidator {
 /**
 * @MethodName: validate
 * @Description:
 * @param: c
 * @return void
 * @throws
 * @date 2023/8/31 15:36
 * @author jhf
 */
  protected  void validate(Controller c){

    setShortCircuit(true);

    validateRequired("customid","title_Valid","自定义项不能为空。");
    validateRequired("codename","title_Valid","名称不能为空。");
    //validateByteString("codename", 1, 50, "title_Valid", "标题长度最多为50字节,每个汉字3个字节");
    validateByteString("codename", 1, 300, "title_Valid", "标题长度最多为300字节,每个汉字3个字节");
  }
 /**
 * @MethodName: handleError
 * @Description:
 * @param: c
 * @return void
 * @throws
 * @date 2023/8/31 15:36
 * @author jhf
 */
  protected void handleError(Controller c){
    TResult _result = new TResult();
    c.keepPara(TsCode.class);
    _result.setState(ContextStateEnum.FAIL);
    _result.setMessage(c.getAttr("title_Valid").toString());
    c.renderJson(_result);
  }

}
